package com.cn.rjt;


public class PerminumCaculator {
    private Integer age;
    private Integer fosterNum;
    private char sex;
    private boolean marry;
    private double point = 0.0,rate;

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getFosterNum() {
        return fosterNum;
    }

    public void setFosterNum(Integer fosterNum) {
        this.fosterNum = fosterNum;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

    public boolean isMarry() {
        return marry;
    }

    public void setMarry(boolean marry) {
        this.marry = marry;

    }

    public PerminumCaculator() {
    }

    public PerminumCaculator(int age, int fosterNum, char sex, boolean marry) {
        this.age = age;
        this.fosterNum = fosterNum;
        this.sex = sex;
        this.marry = marry;
    }

    /**
     *
     * @param age 年龄
     * @param fosterNum 抚养数量
     * @param marry 是否结婚
     * @param sex 性别，M:男 F:女
     * @return point 保险的点数
     */
    public double getPoint(Integer age,Integer fosterNum,boolean marry,char sex) throws InputException{
        assert age != null;
        assert age > 1 && age <100;
        assert fosterNum >= 0 ;
        assert sex == 'F'||sex == 'M';



        setAge(age);
        setFosterNum(fosterNum);
        setSex(sex);
        setMarry(marry);


        if(age>=20&&age<=39){
            this.point += 6;
        }else if(age>=40&&age<=59){
            this.point += 4;
        }else {
            this.point += 2;
        }

        if(sex == 'M'){
            this.point += 4;
        }if(sex == 'F'){
            this.point += 3;
        }

        if(marry == true){
            this.point += 3;
        }else {
            this.point += 5;
        }

        if(fosterNum<=6){
            this.point -= 0.5*fosterNum;
        }if(fosterNum > 6){
            point -= 3;
        }


        return this.point;
    }

    public double getRate() throws InputException{
        if(point>=10){
            this.rate = 0.006;
        }else if(this.point < 10 && point>0){
            this.rate = 0.001;
        }else {
            throw new InputException("输入错误！");
        }
        return this.rate;
    }
}
